//  不要给我WA WA 叫
//  一定AC
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <cmath>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
int a[N];
void solve()
{
     int n;
     cin >> n;
     int ans = 0;
     for(int i = 1; i <= n / 2; i++)
     {
         int j = n - i;
         //cout << i << " " << j << endl;
         if((i & j) == 0) ans++;
     }
     cout << (2 * ans) << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t = 1;
    while(t -- )  solve();
    return 0;
}